//统一管理项目中用户相关的接口
import request from '@/utils/request'
import type { loginFormData } from './type'
import qs from 'qs'
// 项目用户相关的请求地址
enum API {
  // LOGIN_URL = '/admin/acl/index/login',
  LOGIN_URL = '/login',
  USERINFO_URL = '/api/students',
  // LOGOUT_URL = '/admin/acl/index/logout',
  GETSTUDENTS_URL = '/emps',
  ADDSTUDENT_URL = '/emps',
  DELETE_URL = '/emps',
  UPDATA_URL = '/emps',
}

// 登录接口
export const reqLogin = (data: loginFormData) =>
  request.post<any, any>(API.LOGIN_URL, data)

// 获取用户信息接口
export const reqUserInfo = () => request.get<any, any>(API.USERINFO_URL)

// 退出登录
// export const reqLogout = () => request.post<any, any>(API.LOGOUT_URL)

//获取学生数据
export const getStudentsInfo = () => request.get(API.GETSTUDENTS_URL)

//添加学生信息
export const addStudent = (data: any) => request.post(API.ADDSTUDENT_URL, data)

//删除学生信息
export const deleteStudents = (students: any) =>
  request.delete(API.DELETE_URL, {
    params: {
      ids: [...[students]],
    },
    paramsSerializer: (params) => {
      return qs.stringify(params, { arrayFormat: 'comma' })
    },
  })

// 更新学生信息
export const updataStudent = (data: any) => request.put(API.UPDATA_URL, data)
